package Demo;

public class Demo02_Thread {
    public static void main(String[] args) {
        //初始化自定义的线程
        MyThread02 myThread02 = new MyThread02();
        //启动线程，创建PCB，参与CPU调度
        myThread02.start();
        //myThread02.run();  //只是JAVA的一个方法而已

        //主线程的任务
        while (true){
            try {
                //让线程休息一会
                Thread.sleep(1000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
            System.out.println("hello main thread...");
        }
    }
}

class MyThread02 extends Thread{
    public void run(){
        while (true){
            try {
                Thread.sleep(1000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
            System.out.println("hello my thread...");
        }
    }
}
